package com.example.ailiyuncloud.service.Impl;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author: lqj
 * @Date: 2024/04/04/14:10
 * @Description:
 */
public class ThreadNumberServiceImpl implements Runnable {
    public static AtomicInteger number = new AtomicInteger(0);
    public static AtomicInteger number2 = new AtomicInteger(0);
    public static AtomicInteger number3 = new AtomicInteger(0);

    public Integer numberOf = 0;

    public String name = null;


    public ThreadNumberServiceImpl(Integer numberOf, String name) {
        this.numberOf = numberOf;
        this.name = name;
    }

    @Override
    public void run() {
        try {
            if ("1".equals(name)) {
                threadNumberService();
            } else if ("2".equals(name)) {
                threadNumberService2();
            } else {
                threadNumberService3();
            }

        } catch (Exception e) {

        }
    }


    public void threadNumberService() throws Exception {
        for (int i = 0; i < numberOf; i++) {
            number.incrementAndGet();
            //Thread.sleep(10);
        }


    }

    public void threadNumberService2() throws Exception {
        for (int i = 0; i < numberOf; i++) {
            number2.incrementAndGet();
            //Thread.sleep(10);
        }


    }

    public void threadNumberService3() throws Exception {
        for (int i = 0; i < numberOf; i++) {
            number3.incrementAndGet();
            //Thread.sleep(10);
        }


    }

}
